package com.controller.briuptest;

import com.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.pojo.User;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
//登录
@Controller
public class LoginController {
    @Autowired
    private com.service.UserService UserService;
    @RequestMapping(value = "/login",method = RequestMethod.POST)
    @ResponseBody
    public Result login(HttpSession httpSession, String username, String password) throws Exception {
        User user=UserService.login(username,password);
        httpSession.setAttribute("user",user);
        return Result.LoginSUCCESS(user);
    }
}
